package com.pubinfo.passbook.common.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.pubinfo.passbook.common.handler.BankFileUrlListHandler;
import com.pubinfo.passbook.common.handler.PurchaseListTypeHandler;
import com.pubinfo.passbook.common.model.bo.bank.BankApplyReceipt;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.ibatis.type.StringTypeHandler;

/**
 * <p>
 * 
 * </p>
 *
 * @author xuhong
 * @since 2022-05-20
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName(value = "t_bank_apply_receipt",autoResultMap = true)
@ApiModel(value = "TBankApplyReceipt对象", description = "")
@NoArgsConstructor
public class TBankApplyReceipt implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId
    private String id;

    @ApiModelProperty("任务流水号")
    @TableField("task_id")
    private String taskId;

    @ApiModelProperty("银行代码")
    @TableField("platform_id")
    private String platformId;

    @ApiModelProperty("单据类型(0-银行回单 1银行对账单)")
    @TableField("type")
    private String type;

    @ApiModelProperty("对账单类型(0-日对账单,1-月对账单)")
    @TableField("dz_type")
    private String dzType;

    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    /**
     * 修改时间
     */
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty("生成状态\n" +
            "1：已申请\n" +
            "2：文件生成中\n" +
            "3：文件生成成功\n" +
            "4：文件过大，生成失败\n" +
            "5：当前无申请日期范围内的文件\n")
    @TableField("status")
    private Integer status=0;

    @ApiModelProperty("保存请求时发送的json")
    @TableField("content_json")
    private String contentJson;

    @ApiModelProperty("加密后的json报文")
    @TableField("post_json")
    private String postJson;

    @TableField(typeHandler = BankFileUrlListHandler.class)
    private List<String> fileUrl;

    public TBankApplyReceipt(String taskId,BankApplyReceipt bankApplyReceipt,String postJson) {
        this.taskId = taskId;
        this.platformId=bankApplyReceipt.getPlatformId();
        this.type = bankApplyReceipt.getType();
        this.dzType = bankApplyReceipt.getDzType();
        this.contentJson = JSON.toJSONString(bankApplyReceipt);
        this.postJson=postJson;
    }
}
